Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10103 - CheckConvexity removes colinear vertices but stops when surface is determined non-convex, causing vertex size mismatch fatal error #10114

Merged
merged 3 commits into from
Jul 19, 2023

Conversation

jmarrec
Copy link
Contributor

@jmarrec jmarrec commented Jul 18, 2023

Pull request overview

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

```
[ RUN      ] EnergyPlusFixture.SurfaceGeometry_CheckConvexity_ColinearStability
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SurfaceGeometry.unit.cc:3331: Failure
Expected equality of these values:
  6
  floorSurface.Sides
    Which is: 8
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SurfaceGeometry.unit.cc:3350: Failure
Expected equality of these values:
  6
  ceilingSurface.Sides
    Which is: 9
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SurfaceGeometry.unit.cc:3354: Failure
Expected equality of these values:
  floorSurface.Sides
    Which is: 8
  ceilingSurface.Sides
    Which is: 9
```
…surface is determined non-convex, causing vertex size mismatch fatal error
@jmarrec jmarrec added the Defect Includes code to repair a defect in EnergyPlus label Jul 18, 2023
@jmarrec jmarrec self-assigned this Jul 18, 2023
Comment on lines +15791 to +15796
if (state.dataGlobal->DisplayExtraWarnings && surfaceTmp.ExtSolar &&
(state.dataHeatBal->SolarDistribution != DataHeatBalance::Shadowing::Minimal) &&
// Warn only once
surfaceTmp.IsConvex) {
ShowWarningError(state,
format("CheckConvexity: Zone=\"{}\", Surface=\"{}\" is non-convex.",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When warning, do it only once (when surfaceTmp.IsConvex, before that's set to false)

Comment on lines 15814 to +15817
surfaceTmp.IsConvex = false;
break;
// #10103 - We do not want to break early, because we do want to consistently remove colinear vertices
// to avoid potential vertex size mismatch fatal errors
// break;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And do NOT break, so we ensure we do drop all colinear vertices and do not end up with a vertex size mistmatch.

Comment on lines +3279 to +3295
// Test for #10103 - Regardless of the order of the vertices, we should drop colinear vertices consistently to avoid a fatal error due to vertex
// side mismatch
//
// y
// ▲ 7 8 9
// │ ┌─────x────┐
// │ │ │
// │ │ │
// │ │ │
// │5 │ │
// ├──────────┘ │
// │ 6 │
// │ │
// │ │
// │ │10
// └────x─────x─────x────┴─────►
// 4 3 2 1 x
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit test case. We expect 1, 2, 3, and 8 to be dropped, resulting in 6 vertices in the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the fix, the floor is checked in the order show above. so it drops 2 and 3, then finds a non convex situation when checking (5, 6, 7) and bails. We end up with 8 vertices.

For the ceiling, the vertices are reversed. So it drops 8 (shown above, 3 in actual order), finds the non convex situation at (7, 6, 5) (shown above, (4, 5, 6 in actual order)) and bails. We end up with 9 vertices.

(I explained the same on #10103 when I reported the defect)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh this makes sense and is a phenomenal demonstration of the problem and test of the routine. Thanks @jmarrec !

@mjwitte this looks good, but feel free to take a look before this merges.

EXPECT_FALSE(ceilingSurface.IsConvex);
}

EXPECT_EQ(floorSurface.Sides, ceilingSurface.Sides);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before fix:

[ RUN      ] EnergyPlusFixture.SurfaceGeometry_CheckConvexity_ColinearStability
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SurfaceGeometry.unit.cc:3331: Failure
Expected equality of these values:
  6
  floorSurface.Sides
    Which is: 8
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SurfaceGeometry.unit.cc:3350: Failure
Expected equality of these values:
  6
  ceilingSurface.Sides
    Which is: 9
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SurfaceGeometry.unit.cc:3354: Failure
Expected equality of these values:
  floorSurface.Sides
    Which is: 8
  ceilingSurface.Sides
    Which is: 9

@Myoldmopar
Copy link
Member

I don't think we need to hold this up any longer, this is great. Thanks @jmarrec !

@Myoldmopar Myoldmopar merged commit b7a30cf into develop Jul 19, 2023
10 checks passed
@Myoldmopar Myoldmopar deleted the 10103_CheckConvexity_Colinear branch July 19, 2023 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus
Projects
None yet
7 participants